package services;

import java.util.List;

import models.SystemVUserauth;
import models.SystemVUserauthExample;
import models.mapper.SystemVUserauthMapper;

import org.apache.ibatis.session.SqlSession;

import com.aton.db.SessionFactory;

/**
 * 权限服务类
 * @author wangshaoming
 *
 */
public class AuthorityService {
	/**
	 * 检查是否拥有权限
	 * @param id 权限id
	 * @param operatorid 用户编号
	 * @return
	 */
	public static boolean isExist(String id, String operatorid) {
		// TODO Auto-generated method stub
		SqlSession ss = SessionFactory.INSTANCE.getSqlSession();
		try{
			SystemVUserauthMapper mapper=ss.getMapper(SystemVUserauthMapper.class);
			SystemVUserauthExample example=new SystemVUserauthExample();
			SystemVUserauthExample.Criteria c=example.createCriteria();
			c.andIdEqualTo(id);
			c.andOperatoridEqualTo(operatorid);
			List<SystemVUserauth> auths=mapper.selectByExample(example);
			if(auths!=null&&auths.size()>0){
				return true;
			}
			else{
				return false;
			}
		}finally{
			ss.close();
		}
	}
	
}
